package com.neuedu.corejava.ch13.homework;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class ThreadTime extends Thread {
	public static void threadTwo() {
		new Thread(new Runnable() {
			public void run() {
				System.out.println("线程定时器");
				while (true) {
					//Calendar time = Calendar.getInstance();
					Date date=new Date();
					String format = "yyyy-MM-dd HH:mm:ss";
					SimpleDateFormat dateFormat = new SimpleDateFormat(format);
					System.out.println( dateFormat.format(date.getTime()));
					try {
						Thread.sleep(1000);// 这个时间 可以随便定义
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
				}
			}
		}).start();
	}

	public static void main(String[] args) {

		threadTwo();
	}

}
